$(function() {


    function vH() {
        var W = $(window).width();
        var H = $(window).height();
        $(".breadcrumb").css("width", W - 210);
        $(".sidebar").css("height", H - 56);
    }

    $(window).load(function() {
        vH();
    });

    $(window).resize(function() {
        vH();
    });

})

$('.track').click(function() {
    $indicator = $('.indicator');
    if ($indicator.hasClass('switch-on')) {
        $indicator.removeClass('switch-on').addClass('switch-off');
    } else {
        $indicator.removeClass('switch-off').addClass('switch-on');
    }
});

var data = [{
        "order": [1, 3, 4, 5, 7, 1, 9, 4, 6, 9, 1, 2, 1]
    },
    {
        "order": [6, 8, 4, 5, 7, 5, 9, 4, 7, 9, 3, 8, 2]
    },
    {
        "order": [1, 3, 4, 5, 7, 1, 9, 4, 6, 9, 1, 2, 3]
    },
    {
        "order": [6, 8, 4, 5, 7, 5, 9, 4, 7, 9, 3, 8, 4]
    },
    {
        "order": [1, 3, 4, 5, 7, 1, 9, 4, 6, 9, 1, 2, 5]
    },
    {
        "order": [6, 8, 4, 5, 7, 5, 9, 4, 7, 9, 3, 8, 6]
    },
    {
        "order": [1, 3, 4, 5, 7, 1, 9, 4, 6, 9, 1, 2, 7]
    },
    {
        "order": [6, 8, 4, 5, 7, 5, 9, 4, 7, 9, 3, 2, 8]
    },
    {
        "order": [6, 8, 4, 5, 7, 5, 9, 4, 7, 9, 3, 2, 9]
    }
];
var index = 0; //第一个选手的对应数组
var k = 0;
var draw;
var draw2;
var speed = 20; //循环速度，越小越快


// 单击开始后无限循环
function startRandom() {
    console.log(index);
    clearInterval(draw);
    clearInterval(draw2);
    k = 0;
    var arr = data[index].order;
    var num = arr.length - 1;
    draw = setInterval(function() {
        $('#selected').text(arr[GetRnd(0, num)]);
    }, speed);

}

// 点击停止后减速跳转到当前序列最后一位数字
function stopRandom() {
    clearInterval(draw);
    clearInterval(draw2);
    slowDown();
    k = 0;
}

// 当前循环序列里随机取值
function GetRnd(min, max) {
    return parseInt(Math.random() * (max - min + 1));
}


// 减速处理
function slowDown() {
    var arr = data[index].order;
    if (k < data[index].order.length) {
        $('#selected').text(arr[k]);
        draw2 = setTimeout(slowDown, 0.5 * k * speed);
    } else {
        index++;
    }
    k++;
}
$(function() {
    $('.button-ss').click(function() {
        $('.bg-body').show();
        $('html').addClass("bg-fixed");
    });
    $('.tishi-close').click(function() {
        $('.bg-body').hide();
        $('html').removeClass('bg-fixed');
    });
    $('.pull-left').click(function() {
        $('.bg-body').hide();
        $('html').removeClass('bg-fixed');
    });
    //弹出框        

    $('.active').click(function() {
        $(this).addClass('active-bg');
        $(this).siblings().removeClass('active-bg');
    });
}); //点击事件，背景改变

$(document).ready(function() {

    $(".checkboxone").each(function() {
        $(this).click(function(e) {
            $(this).parent().next('.boxone').slideToggle();
        });
    });
}); //循环添加样式

$(document).ready(function(){
  $(".newly").click(function(){
    $("table").attr(".newly-tr");
  });
});



